package com.ruoyi.web.controller.his;


import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.his.domain.HisDockor;
import com.ruoyi.his.domain.HisRestrictedDrug;
import com.ruoyi.his.domain.vo.HisRestrictedDrugVo;
import com.ruoyi.his.service.IHisRestrictedDrugService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/his/drug")
public class HisRestrictedDrugController extends BaseController {
    @Autowired
    private IHisRestrictedDrugService ihisRestrictedDrugService;


    /**
     * 根据
     */
    @GetMapping("/list")
    public TableDataInfo list(HisRestrictedDrug hisRestrictedDrug) {
        startPage();
        List<HisRestrictedDrug> list = ihisRestrictedDrugService.selectHisRestrictedDrugList(hisRestrictedDrug);
        return getDataTable(list);
    }
    /**
     * 获取【请填写功能名称】详细信息
     */
//    @PreAuthorize("@ss.hasPermi('his:dockor:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {

        return AjaxResult.success(ihisRestrictedDrugService.selectHisRestrictedDrugById(id));
    }

    @DeleteMapping(value = "/{id}")
    public AjaxResult delete(@PathVariable("id") Long id) {
        return AjaxResult.success(ihisRestrictedDrugService.deleteHisRestrictedDrugById(id));
    }

    /**
     * 修改【请填写功能名称】
     */
//    @PreAuthorize("@ss.hasPermi('his:drug:edit')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HisRestrictedDrug hisRestrictedDrug)
    {
        return toAjax(ihisRestrictedDrugService.updateHisRestrictedDrug(hisRestrictedDrug));
    }

    @PostMapping
    public AjaxResult add(@RequestBody HisRestrictedDrug hisRestrictedDrug)
    {
        return toAjax(ihisRestrictedDrugService.insertHisRestrictedDrug(hisRestrictedDrug));
    }
}
